﻿@using DTcms.Common;
@{
    ViewBag.Title = "操作管理";
}
<!--导航栏-->
<div class="pageheader">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
            <li><a href="javascript:;">系统管理</a> </li>
            <li><a href="javascript:;">操作管理</a> </li>
        </ul>
    </div>
</div>
<!--/导航栏-->
<!--工具栏-->
<div class="layui-fluid">
    <div class="layui-card layui-tab">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="menu-list">
                        <div class="layui-inline">
                            <div class="layui-input-inline mr0">
                                <input id="txtKeywords" class="layui-input" type="text" placeholder="输入关键字" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn layui-btn-normal layui-btn-sm" id="btnSearchAuth" data-type="btnSearch">
                                <i class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-btn-group">
                            <a data-type="btnAdd" class="layui-btn icon-btn layui-btn-normal layui-btn-sm" href="../settings/action_edit?action=@DTEnums.ActionEnum.Add"><i class="iconfont icon-close1"></i> 新增</a>
                            <a data-type="btnDelete" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-delete"></i> 删除</a>
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                <thead>
                    <tr>
                        <th lay-data="{checkbox:true}"></th>
                        <th lay-data="{field:'action_code'}">操作编码</th>
                        <th lay-data="{field:'action_name'}">操作名称</th>
                        <th lay-data="{field:'icon',templet: '#icon'}">操作图标</th>
                        <th lay-data="{field:'method'}">操作方法</th>
                        <th lay-data="{field:'sort_id'}">排序号</th>
                        <th lay-data="{field:'is_lock',templet: '#switchTpl'}">状态</th>
                        <th lay-data="{field:'add_time'}">创建时间</th>
                        <th lay-data="{templet: '#bar', fixed: 'right'}">操作</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<script type="text/html" id="icon">
    <i class="{{d.icon}}"></i>
</script>
<script type="text/html" id="bar">
    <a href="../settings/action_edit?action=@DTEnums.ActionEnum.Edit&id={{d.id}}" class="layui-btn layui-btn-primary layui-btn-xs">修改</a>
</script>
<script type="text/html" id="switchTpl">
    <input type="checkbox" name="is_lock" value="{{d.id}}" lay-skin="switch" lay-text="显示|不显示" lay-filter="red" {{ d.is_lock == 0 ? 'checked' : '' }}>
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'cmswh'], function () {
            var table = layui.table, form = layui.form, cmswh = layui.cmswh, $ = layui.jquery;

            cmswh.dataBind('actionlist');
            var active = {
                btnDelete: function () {
                    cmswh.batOperate('UrlRewriteDelete', 'name', "本操作会导致网站前台无法运作，是否继续？");
                },
                btnSearch: function () {
                    table.reload('ltable', { page: { curr: 1 }, where: getcond() });
                }
            };
            form.on('select(btnSearch)', function (data) {
                var type = "btnSearch";
                active[type] ? active[type].call(this) : '';
            });
            $('.layui-inline .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            /*拼接条件返回postdata*/
            function getcond() {
                var keywords = $("#txtKeywords").val();
                var postdata = { keywords: keywords };
                return postdata;
            }
        });
    </script>
}